package cc.lj.internal.payment.domain.settlement.service.impl;

import cc.lj.internal.payment.domain.settlement.repository.ICouponsCapLogRepository;
import cc.lj.internal.payment.domain.settlement.repository.ICouponsSubsidyDetailRepository;
import cc.lj.internal.payment.domain.settlement.repository.ICouponsSubsidyRepository;
import cc.lj.internal.payment.domain.settlement.service.ICouponsCapLogDomainService;
import cc.lj.internal.payment.domain.settlement.service.ICouponsSubsidyDomainService;
import cc.lj.internal.payment.domain.settlement.vo.CouponsCapLogDO;
import cc.lj.internal.payment.domain.settlement.vo.CouponsSubsidyDO;
import cc.lj.internal.payment.domain.settlement.vo.CouponsSubsidyDetailDO;
import cc.lj.internal.payment.domain.settlement.vo.convert.CouponsCapLogPOConvertDO;
import cc.lj.internal.payment.domain.settlement.vo.convert.CouponsSubsidyDetailPOConvertDO;
import cc.lj.internal.payment.domain.settlement.vo.convert.CouponsSubsidyPOConvertDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 电子券封顶额计算日志表 domain service 实现类
 * @author liangxifeng
 * @date 2022/10/23 17:13
 */
@Service("couponsCapLogDomainServiceImpl")
@Slf4j
public class CouponsCapLogDomainServiceImpl implements ICouponsCapLogDomainService {
    @Resource(name = "couponsCapLogRepository")
    private ICouponsCapLogRepository repository;

    @Resource(name = "couponsSubsidyDetailRepository")
    private ICouponsSubsidyDetailRepository detailRepository;

    @Override
    public Integer insert(CouponsCapLogDO logDO) {
        return repository.insert(CouponsCapLogPOConvertDO.INSTANCE.convert(logDO));
    }

    @Override
    public CouponsCapLogDO getById(Integer id) {
        return CouponsCapLogPOConvertDO.INSTANCE.convert( repository.getById(id) );
    }


    @Override
    public List<CouponsCapLogDO> getList(CouponsCapLogDO logDO) {
        return repository.getList(CouponsCapLogPOConvertDO.INSTANCE.convert(logDO))
                .stream()
                .map( x-> CouponsCapLogPOConvertDO.INSTANCE.convert(x))
                .collect(Collectors.toList());
    }
}
